package com.lnking.lnkingplace.controller;


import com.lnking.common.http.ReturnResult;

import com.lnking.lnkingplace.model.dto.recordUser.RecordDetailDto;
import com.lnking.lnkingplace.model.dto.specialPlace.SpecialPlaceDetailDto;
import com.lnking.lnkingplace.model.request.specialPlace.SpecialPlaceAddRequest;
import com.lnking.lnkingplace.model.request.specialPlace.SpecialPlaceSearchRequest;
import com.lnking.lnkingplace.model.request.specialPlace.SpecialPlaceUpdateRequest;
import com.lnking.lnkingplace.service.ISpecialPlaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 场所信息表 前端控制器
 * </p>
 *
 * @author sn
 * @since 2022-09-18
 */
@RestController
@Api(tags = "特殊场所")
@RequestMapping("/special-place")
public class SpecialPlaceController {


    @Autowired
    ISpecialPlaceService specialPlaceService;

    @ApiOperation("新增")
    @PostMapping("/add")
    public ReturnResult add(@RequestBody @Valid SpecialPlaceAddRequest params) throws Exception {
        specialPlaceService.add(params);
        return ReturnResult.success();
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public ReturnResult delete(@PathVariable("id") String id) {
        specialPlaceService.removeById(id);
        return ReturnResult.success();
    }

    @ApiOperation("编辑")
    @PostMapping("/update")
    public ReturnResult update(@RequestBody @Valid SpecialPlaceUpdateRequest params) throws Exception {
        specialPlaceService.update(params);
        return ReturnResult.success();
    }

    @ApiOperation("查询列表")
    @GetMapping("/list")
    public ReturnResult getList(SpecialPlaceSearchRequest params) {
        return ReturnResult.success(specialPlaceService.pageList(params));
    }


    @ApiOperation("获取特殊场所详情")
    @GetMapping("/{id}")
    public ReturnResult getDetail(@PathVariable("id") String id) {
        SpecialPlaceDetailDto user = specialPlaceService.getUserDetailById(id);
        return ReturnResult.success(user);
    }

}
